package org.dromara.Nyt7PolicyInsurance.domain;

import org.dromara.Nyt7FarmerInsuranceInfo.domain.Nyt7FarmerInsuranceInfo;
import org.dromara.Nyt7FarmerInsuranceInfo.domain.vo.Nyt7FarmerInsuranceInfoVo;
import org.dromara.Nyt7PlotDetailInfo.domain.Nyt7PlotDetailInfo;
import org.dromara.Nyt7PlotDetailInfo.domain.vo.Nyt7PlotDetailInfoVo;
import org.dromara.Nyt7PolicyInsurance.domain.vo.Nyt7PolicyInsuranceVo;
import org.dromara.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.dromara.system.domain.SysPost;
import org.dromara.system.domain.vo.SysPostVo;

import java.io.Serial;
import java.math.BigDecimal;

/**
 * 保单查询对象 nyt_7_policy_insurance
 *
 * @author Lion Li
 * @date 2025-01-09
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("nyt_7_policy_insurance")
public class Nyt7PolicyInsurance extends TenantEntity {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(value = "id")
    private Long id;

    /**
     * 保单号
     */
    private String policyNumber;

    /**
     * 投保标识
     */
    private String insuranceIdentifier;

    /**
     * 投保总户数
     */
    private Long totalInsuredHouseholds;


    /**
     * 作物代码
     */
    private String cropCode;

    /**
     * 险种代码
     */
    private String insuranceTypeCode;

    /**
     * 总承包面积
     */
    private Double totalContractArea;

    /**
     * 保费总额
     */
    private BigDecimal totalPremium;

    /**
     * 用户自缴总额
     */
    private BigDecimal totalSelfPaidByUser;

    /**
     * 中央财政补贴总额
     */
    private BigDecimal totalCentralFiscalSubsidy;

    /**
     * 省级财政补贴总额
     */
    private BigDecimal totalProvincialFiscalSubsidy;

    /**
     * 地市财政补贴总额
     */
    private BigDecimal totalMunicipalFiscalSubsidy;

    /**
     * 区县财政补贴总额
     */
    private BigDecimal totalDistrictAndCountyFiscalSubsidy;

    /**
     * 其他财政补贴总额
     */
    private BigDecimal totalOtherFiscalSubsidies;

    /**
     * 保险公司id
     */
    private Long postId;

    /**
     * 地块id
     */
    private Long plotId;

    /**
     * 农户id
     */
    private Long farmerId;

    /**
     * 删除标志（0代表存在 2代表删除）
     */
    @TableLogic
    private String delFlag;


    /**
     * 保险公司
     */
    @TableField(exist = false)
    private SysPost sysPost;

    /**
     * 地块信息
     */
    @TableField(exist = false)
    private Nyt7PlotDetailInfo plotDetailInfo;

    /**
     * 农户信息
     */
    @TableField(exist = false)
    private Nyt7FarmerInsuranceInfo farmerInsuranceInfo;

    public void addFields(Nyt7PolicyInsurance other) {
        this.totalInsuredHouseholds += other.getTotalInsuredHouseholds();
        this.totalContractArea += other.getTotalContractArea();
        this.totalPremium = this.totalPremium.add(other.getTotalPremium());
        this.totalSelfPaidByUser = this.totalSelfPaidByUser.add(other.getTotalSelfPaidByUser());
        this.totalCentralFiscalSubsidy = this.totalCentralFiscalSubsidy.add(other.getTotalCentralFiscalSubsidy());
        this.totalProvincialFiscalSubsidy = this.totalProvincialFiscalSubsidy.add(other.getTotalProvincialFiscalSubsidy());
        this.totalMunicipalFiscalSubsidy = this.totalMunicipalFiscalSubsidy.add(other.getTotalMunicipalFiscalSubsidy());
        this.totalDistrictAndCountyFiscalSubsidy = this.totalDistrictAndCountyFiscalSubsidy.add(other.getTotalDistrictAndCountyFiscalSubsidy());
        this.totalOtherFiscalSubsidies = this.totalOtherFiscalSubsidies.add(other.getTotalOtherFiscalSubsidies());
    }
}
